Dev#170
Conversation
…ayro_svg` to replace `pdf-into-svg` for improved consistency
Jorgedanisc
There was a problem hiding this comment.
Pull request overview
This PR implements a major refactoring of the ducsvg package, replacing the C# .NET-based pdf-into-svg library with a custom Rust/WASM implementation using the hayro and hayro-svg libraries. The change provides a more native, self-contained PDF-to-SVG conversion solution while maintaining the existing two-step conversion approach (DUC → PDF → SVG).
Key Changes:
- Replaced
pdf-into-svgdependency with a custom Rust WASM module usinghayro-svg - Added new Rust crate
pdf2svgwithin the ducsvg package for PDF-to-SVG conversion - Updated infrastructure configuration to use dynamic region variable and enable Cloudflare proxy
- Added
background_colorfield to all ducpdf test cases for comprehensive testing - Renamed
sst:wraptosst:shellacross package scripts for clearer naming
Reviewed changes
Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sst.config.ts | Changed region from hardcoded string to variable reference; enabled Cloudflare DNS proxy for both web and docs domains |
| packages/ducsvg/vite.config.mts | Removed pdf-into-svg from external dependencies and build globals; added emptyOutDir: false to preserve WASM artifacts |
| packages/ducsvg/tsconfig.json | Added pkg and src/pdf2svg/src to exclude list for TypeScript compilation |
| packages/ducsvg/src/wasm.ts | New file re-exporting WASM bindings from dist directory |
| packages/ducsvg/src/pdf2svg/src/lib.rs | New Rust implementation using hayro for PDF parsing and hayro-svg for SVG conversion |
| packages/ducsvg/src/pdf2svg/index.ts | TypeScript wrapper for initializing and calling the WASM module |
| packages/ducsvg/src/pdf2svg/Cargo.toml | Cargo configuration for the new pdf2svg Rust crate |
| packages/ducsvg/src/ducToSvg.ts | Updated to use new local pdf2svg module instead of pdf-into-svg package |
| packages/ducsvg/package.json | Removed pdf-into-svg dependency; added build scripts for WASM compilation; added ./pkg export |
| packages/ducsvg/README.md | Updated documentation to reflect use of hayro and hayro_svg instead of pdf-into-svg |
| packages/ducpdf/src/duc2pdf/tests/test_integration.rs | Added background_color field to all test cases; added new block_ids and instance_id fields to test helper |
| packages/ducpdf/src/duc2pdf/src/lib.rs | Code formatting improvements for error handling calls |
| packages/ducpdf/src/duc2pdf/index.ts | Removed trailing whitespace |
| package.json | Renamed sst:wrap script to sst:shell across all SST-related commands |
| bun.lock | Removed pdf-into-svg dependency from lock file |
| Cargo.toml | Added packages/ducsvg/src/pdf2svg to workspace members |
| Cargo.lock | Added dependencies for hayro, hayro-svg, and related crates |
| .vscode/settings.json | Added pdf2svg Cargo.toml to Rust analyzer linked projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Re-export WASM bindings from dist for bundled distribution | ||
| export * from '../dist/pdf2svg'; | ||
| export { default } from '../dist/pdf2svg'; No newline at end of file |
There was a problem hiding this comment.
This file re-exports from ../dist/pdf2svg, but the dist directory is generated during the build process and won't exist in the source tree. This creates a circular dependency where TypeScript compilation requires the WASM build output to already exist. Consider importing directly from ../pkg/pdf2svg instead, or restructuring the build to ensure the WASM build happens before TypeScript compilation attempts to resolve this import.
| // Re-export WASM bindings from dist for bundled distribution | |
| export * from '../dist/pdf2svg'; | |
| export { default } from '../dist/pdf2svg'; | |
| // Re-export WASM bindings from pkg for development and build | |
| export * from '../pkg/pdf2svg'; | |
| export { default } from '../pkg/pdf2svg'; |
| is_deleted: false, | ||
| group_ids: vec![], | ||
| region_ids: vec![], | ||
|
|
There was a problem hiding this comment.
This line contains only whitespace and should be removed to maintain code cleanliness.
| "./pkg": { | ||
| "types": "./pkg/pdf2svg.d.ts", | ||
| "import": "./pkg/pdf2svg.js", | ||
| "default": "./pkg/pdf2svg.js" | ||
| } |
There was a problem hiding this comment.
The ./pkg export points to the pkg directory, but this directory is not included in the files array (lines 47-50). This means when the package is published to npm, the pkg directory won't be included, making the ./pkg export unusable. Either add pkg to the files array or remove this export if the WASM files are meant to be consumed only from the dist directory (which is included in files).
| export interface SvgPage { | ||
| svg: string; | ||
| } |
There was a problem hiding this comment.
The SvgPage interface is missing a pageIndex property that is referenced in the test file at tests/duc-to-svg.unit.test.ts:37. The test tries to access page.pageIndex to generate unique filenames, but this property doesn't exist on the interface. Either add a pageIndex?: number property to the interface and populate it in the Rust code, or update the test to use array indices instead.
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.3.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.2.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.1.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
No description provided.